/* 
 * Copyright (C) 2012 Martin Řehánek <Martin.Rehanek at mzk.cz>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


goog.provide('kramerius.audio.ui.VolumeInfo');

goog.require('kramerius.audio.ui.PlayerComponent');
goog.require('goog.dom');


/**
 * @constructor 
 * @param {Element} container Element containing this component.
 * @param {kramerius.audio.Controller} controller Controller of the audio player.
 */
kramerius.audio.ui.VolumeInfo = function(container, controller){
    kramerius.audio.ui.PlayerComponent.call(this, container, controller);
    this.controller_.setVolumeInfo(this);
    this.clear();
    this.volume_ = undefined;
};
goog.inherits(kramerius.audio.ui.VolumeInfo, kramerius.audio.ui.PlayerComponent);


kramerius.audio.ui.VolumeInfo.prototype.clear = function(){
    this.volume_ = 0;
    this.render_();
};


/**
 * Updates and renders volume level.
 * @param {number} volume Actual volume level
 */
kramerius.audio.ui.VolumeInfo.prototype.setVolume = function(volume){
    this.volume_ = volume;
    this.render_();
};

/** @private */
kramerius.audio.ui.VolumeInfo.prototype.render_ = function(){
    var text = this.volume_ + ' %';
    this.setContent_(text);
};


/** @private **/
kramerius.audio.ui.VolumeInfo.prototype.setContent_ = function(content){
    goog.dom.setTextContent(this.container_, content);
};
